package cn.ciis.sys.permission;

import cn.ciis.basic.base.BaseController;
import cn.ciis.basic.model.Permission;
import com.jfinal.aop.Inject;
import com.jfinal.kit.Ret;
import com.jfinal.plugin.activerecord.Page;

/**
 * 权限管理
 *
 * @author 冉志林
 */
public class PermissionAdminController extends BaseController {

  @Inject
  PermissionAdminService srv;

  @Notes(value = "权限管理")
  @Remark(value = "权限列表")
  public void index() {
    Permission mode = getModel(Permission.class, "", true);
    Page<?> paginate =srv.paginate(getInt(PAGENUMBER, 1), getInt(PAGESIZE, 10), mode);
    kModel(mode, paginate);
  }

  @Remark(value = "权限删除")
  public void deletes(String ids) {
    renderJson(srv.delete(ids));
  }

  @Remark(value = "权限添加或编辑页")
  public void addOrEdit(Integer id) {
    kAddOrEdit(srv.findById(id));
  }

  @Remark(value = "权限保存或修改")
  public void saveOrUpdate() {
    Permission bean = getBean(Permission.class);
    renderJson(srv.saveOrUpdate(bean));
  }

  @Remark(value = "权限一键同步")
  public void sync() {
    Ret ret = srv.sync();
    renderJson(ret);
  }
}
